package com.caigou.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import jiliang.purchase.demo.BusinessProcessing;
import jiliang.purchase.demo.PersonObject;

import com.caigou.service.TiXingService;

public class TiXingServlet extends HttpServlet {

	/**
	 * The doGet method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to get.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	private TiXingService TXS = new TiXingService();
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		HttpSession session = request.getSession();
		request.setCharacterEncoding("utf-8");
		PersonObject PO = new PersonObject();
		
		PO = (PersonObject)session.getAttribute("Person");
		if(PO != null)
		{
		/*//System.out.println(TXS.getNumber(PO.getJs_id()));
		//System.out.println("<tr height='30'>"+
				"<td><a>气瓶增置（充装）申购相关事务/a></td>"+
				"<td align='center'>8</td></tr>"+
				"<tr height='30'><td><a>校重点监管危化品申领相关事务</a></td>"+
				"<td align='center'>9</td>"+
				"</tr>"+
				"<tr height='30'>"+
				"<td><a>非校重点监管危化品申购相关事务</a></td>"+
				"<td align='center'>26</td>"+
				"</tr>"+
				"<tr height='30'><td><a href=\"BusinessProcessServlet\">货物/服务申购相关事务</a></td><td align='center'>107</td></tr>");*/
			
			long overInfo = 0;
			long overInfo2 = 0;
			long overInfo3 = 0;
			if(!PO.getJs_id().contains(",20,"))
			{
				overInfo = TXS.getNumber2(PO.getXingming());
			}
			//System.out.println(overInfo);
			if(PO.getXingming().equals("王琳") | PO.getXingming().equals("王雯颜")|  PO.getXingming().equals("孟祥凤") | PO.getJs_id().contains(",20,"))
			{
				overInfo2 = TXS.getNumber3(PO.getXingming(),PO.getJs_id());
			}
			overInfo3 = TXS.getNumber(PO.getJs_id(),PO.getXingming());
			//System.out.println(overInfo3);
			response.setCharacterEncoding("utf-8");
			response.setContentType("text/plain;charset=utf-8");
		response.getWriter().print("<tr height='30'>"+
						"<td><a>气瓶增置（充装）申购相关事务</a></td>"+
						"<td align='center'>8</td></tr>"+
						"<tr height='30'><td><a>校重点监管危化品申领相关事务</a></td>"+
						"<td align='center'>9</td>"+
						"</tr>"+
						"<tr height='30'>"+
						"<td><a>非校重点监管危化品申购相关事务</a></td>"+
						"<td align='center'>26</td>"+
						"</tr>"+
						"<tr height='30'><td><a href=\"BusinessProcessServlet\">货物/服务申购相关事务</a></td><td align='center'>"+(overInfo3+overInfo+overInfo2)+"</td></tr>");
		}
	}

	/**
	 * The doPost method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to post.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doGet(request,response);
	}

}
